/**
 *WeiboDetailActiivity.java
 *2012-4-21 下午09:36:43
 *Touch Android
 *http://bbs.droidstouch.com
 */
package com.droidstouch.iweibo.ui;

import java.util.HashMap;
import java.util.Map;

import weibo4android.Status;

import com.droidstouch.iweibo.R;
import com.droidstouch.iweibo.app.SimpleWeiboManager;
import com.droidstouch.iweibo.bean.Task;
import com.droidstouch.iweibo.imgCache.SimpleImageLoader;
import com.droidstouch.iweibo.logic.MainService;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * @author <a href="http://bbs.droidstouch.com">Touch Android</a>
 *
 */
public class WeiboDetailActiivity extends Activity implements IWeiboActivity
{

	
	
	private ImageView head;
	private TextView name;
	private TextView weiboMsg;
	
	private long status_id;
	
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.weibodetail);
		
		init();
		newTask();
		
	}
	
	
	private void newTask()
	{
		Map<String, Object> taskParams = new HashMap<String, Object>(1);
		taskParams.put("status_id", status_id);
		Task task = new Task(Task.STATUS_SHOW, taskParams);
		MainService.newTask(task);
		
	}
	

	/* (non-Javadoc)
	 * @see com.droidstouch.iweibo.ui.IWeiboActivity#init()
	 */
	@Override
	public void init()
	{
		
		head = (ImageView) this.findViewById(R.id.img_profile_preview);
		name = (TextView)this.findViewById(R.id.txt_profile_name);
		weiboMsg = (TextView) this.findViewById(R.id.txt_weibo_message);
		
		
		MainService.addActivity(this);
		status_id = getIntent().getLongExtra(HomeActivity.STATUS_ID, 0);
		
	}

	public void refresh(Object... params)
	{
		
		Status s = (Status) params[0];
		
		name.setText(s.getUser().getName());
		SimpleImageLoader.showImg(head, s.getUser().getProfileImageURL().toString());
		SimpleWeiboManager.display(weiboMsg, s.getText());
		
		
	}
	
}
